<template>
  <div class="conMain" >
    <el-card  class="box-card" >
      <div slot="header" class="topfix">
          <el-form   :inline="true"  :model="params" size="small" class="goodsForm"  label-width="100px">

              <el-form-item label="订单ID">
                  <el-input clearable v-model="params['s_order*id']"  placeholder="请输入订单ID" />
              </el-form-item>
              <el-form-item label="订单编号">
                  <el-input clearable v-model="params['s_order*sn']"  placeholder="请输入订单编号" />
              </el-form-item>
              <el-form-item label="第三方单号">
                  <el-input clearable v-model="params['s_order*orderno']"  placeholder="请输入第三方单号" />
              </el-form-item>
              <el-form-item label="订购号码">
                  <el-input clearable v-model="params['s_order*phone']"  placeholder="请输入订购号码" />
              </el-form-item>

              <el-form-item label="创建时间" prop="s_createtime">
                  <el-date-picker
                      v-model="params.s_createtime"
                      type="daterange"
                      value-format="yyyy-MM-dd"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                  />
              </el-form-item>

              <el-form-item label=" ">
                <el-button type="primary"  size="small" class="searchBtn" @click="handleSearch" icon='el-icon-search'>搜索</el-button>
                <el-button type="danger" v-has="'cha/cleardata'"  size="small"  @click="clearData" >清除查单记录</el-button>

              </el-form-item>
          </el-form>

      </div>
      <el-table v-loading="loading"  :data="list" style="width: 100%" :empty-text='emtypetxt'>
          <el-table-column prop="id" label="序号" align="center" width="100" />
          <el-table-column prop="order.id" label="订单ID" align="center" width="100" />
          <el-table-column prop="order.sn" label="订单编号" align="center"  />
          <el-table-column prop="order.orderno" label="第三方单号" align="center"  />
          <el-table-column prop="order.phone" label="订购号码" align="center"  />
          <el-table-column prop="u_status_text" label="接口返回" :show-overflow-tooltip="true" align="center"  />
          <el-table-column prop="memo" label="备注" align="center"  />
          <el-table-column prop="createtime" label="创建时间" align="center"  />

      </el-table>
      <div class="pagination">
          <el-pagination
            :current-page="params.page"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="params.pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
      </div>
    </el-card>

  </div>
</template>

<script>

import { cha_index,cha_clear } from  '@/api/service'

export default {
  data() {
    return {
      total:0,
      loading:true,
      emtypetxt:'',
      list: [],
      params: {
        's_order*id':'',
        's_order*sn':'',
        's_order*orderno':'',
        's_order*phone':'',
        s_createtime:'',
        ss_createtime:'BETWEEN',
        page: 1,
        pagesize:10,
      },
    }
  },
  created() {

    this.getList()
  },
  methods: {
    getList(page) {
      this.params.page = page?page:this.params.page;
      this.emtypetxt='加载中...';
      this.loading=true;
      cha_index(this.params).then(res => {
        this.list=res.data.list
        this.total=res.data.total
        this.loading = false
        if(this.list.length==0){
          this.emtypetxt='暂无数据'
        }
      })
    },
    handleSearch(){
      this.getList(1)
    },
    //分页
    handleSizeChange(val) {
      this.params.pagesize = val
      this.getList(1)
    },
    handleCurrentChange(val) {
      this.params.page = val
      this.getList()
    },
    clearData(){
      let _this=this;
      _this.$modalSure('您确定要清除1天前查单记录嘛？').then(() => {
        cha_clear().then(res => {
          _this.$message.success(res.msg)
          _this.getList()
        })
      })
    }

  },
}
</script>

<style lang="scss" scoped>


</style>
